<template>
  <section class="modlude">
    <el-form :inline="true" :model="formSearch" class="form_inline">
      <!-- <el-form-item label="所属组织" size="small">
          <el-cascader ref="cascader" v-model="option1" :options="dataTree" :props="defaultProps2"
              @change="handleChange" clearable></el-cascader>
      </el-form-item> -->
      <el-form-item label="选择项目" size="small">
        <el-select v-model="formSearch.projectId" placeholder="请选择项目">
          <el-option v-for="(item,index) in xqTree" :label="item.name" :value="item.id" :key="index">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="概述" size="small">
        <el-input v-model="formSearch.title" placeholder="请输入概述"></el-input>
      </el-form-item>
      <!-- <el-form-item label="维保类型" size="small">
        <el-select v-model="formSearch.typeId" placeholder="请选择维保类型">
          <el-option label="全部" :value="''"></el-option>
          <el-option v-for="(item,index) in getnamr" :label="item.name" :value="item.id" :key="item.id">
          </el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item label="用户名" size="small">
        <el-input v-model="formSearch.nickname" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item label="审核人员" size="small">
        <el-input v-model="formSearch.manager" placeholder="请输入审核人员"></el-input>
      </el-form-item>
      <el-form-item label="费用" size="small">
        <el-input v-model="formSearch.pushCount" placeholder="请输入费用"></el-input>
      </el-form-item>
      <el-form-item label="目前状态" size="small">
        <el-select v-model="formSearch.status" placeholder="请选择目前状态">
          <el-option label="全部" :value="''"></el-option>
          <el-option label="待派单" :value="1"></el-option>
          <el-option label="已派单" :value="2"></el-option>
          <el-option label="已接单" :value="3"></el-option>
          <el-option label="已完成" :value="4"></el-option>
          <el-option label="未通过审核" :value="5"></el-option>
          <el-option label="已审核" :value="6"></el-option>
          <!-- <el-option label="待回访" :value="7"></el-option>
          <el-option label="已回访" :value="8"></el-option> -->
          <el-option label="已取消" :value="9"></el-option>
          <el-option label="待关单审核" :value="10"></el-option>
          <el-option label="已关单" :value="11"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="申请时间" size="small">
        <el-date-picker v-model="formSearch.checkTime" type="datetime" value-format="timestamp" placeholder="申请时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="派单时间" size="small">
        <el-date-picker v-model="formSearch.opertime" type="datetime" value-format="timestamp" placeholder="派单时间">
        </el-date-picker>
      </el-form-item>
      <!-- v-if="$root.btnControl.find(item=>item=='view')" -->
      <el-form-item>
        <el-button size="small" @click="handleCurrentPage(1)">查 询</el-button>
      </el-form-item>
      <!-- v-if="$root.btnControl.find(item=>item=='add')" -->
      <el-form-item>
        <el-button size="small" @click="showAddBall=true,fileList=[]">添加维保单</el-button>
      </el-form-item>
      <el-form-item>
        <el-button size="small" @click="goProperty_type">去配置</el-button>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="danger" @click="delData()">删除</el-button>
      </el-form-item>

    </el-form>
    <el-table ref="table" :data="formData" style="width: 100%" stripe @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" fixed></el-table-column>
      <!-- <el-table-column prop="id" label="编号"></el-table-column> -->
      <el-table-column prop="desc" label="维保描述"  show-overflow-tooltip></el-table-column>
      <!-- <el-table-column prop="typeName" label="类型" width="100" show-overflow-tooltip></el-table-column> -->
      <el-table-column prop="nickname" label="申请人姓名"  show-overflow-tooltip></el-table-column>
      <el-table-column prop="address" label="申请地址"  show-overflow-tooltip></el-table-column>
      <el-table-column prop="picture" label="图片">
        <template slot-scope="scope">
          <img v-for="item in scope.row.picture" :key="item" :src="item" alt
            style="height:35px;width:35px;cursor: pointer;" @click="checkImg(item)" />
        </template>
      </el-table-column>
      <!-- <el-table-column prop="appointmentTime" label="预约开始" width="150">
        <template slot-scope="{row}">{{ Date.formatTime(row.appointmentTime) }}</template>
      </el-table-column> -->
      <el-table-column prop label="状态" >
        <template slot-scope="scope">
          <div v-if="scope.row.closeStale!=1">
            {{
            scope.row.status == 1 ? '待派单' : scope.row.status == 2 ? '已派单' : scope.row.status == 3 ? '已接单' :
            scope.row.status == 4 ? '已完成' : scope.row.status == 5 ? '待审核' : scope.row.status == 6 ? '已审核' :
            scope.row.status == 7 ? '待回访' : scope.row.status == 8 ? '已回访' : scope.row.status == 9 ? '已取消' :
            scope.row.status == 10 ? '待关单审核' : '已关单'
            }}
          </div>
          <div v-else>已关单</div>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="payStatus" label="支付状态">
        <template slot-scope="{row}">
          {{ row.refundStatus === 'SUCCESS' ? '已退款' : ['未支付', '已支付'][row.payStatus] }}
        </template>
      </el-table-column> -->
      <!-- <el-table-column prop="payee" label="支付人员"></el-table-column>
      <el-table-column prop="payeeTime" label="支付时间" width="150">
        <template slot-scope="{row}">
          {{ Date.formatTime(row.payeeTime) }}
        </template>
      </el-table-column>
      <el-table-column prop="verifyStatus" label="核销状态">
        <template v-slot="{row}">
          <span>{{ ['未核销', '已核销'][+row.verifyStatus] }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="verifyDate" label="核销时间" width="150">
        <template slot-scope="{row}">
          {{ Date.formatTime(row.verifyDate) }}
        </template>
      </el-table-column>
      <el-table-column prop="unitPrice" label="费用（元）" width="100px"></el-table-column> -->
      <el-table-column prop="addType" label="添加类型" >
        <template v-slot="{row}">
          <span>{{ ['', '移动端添加', '后台添加'][row.addType] }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="typeName" label="服务类型">
        <template slot-scope="scope">{{ scope.row.typeService == 0 ? '公区维保' : scope.row.typeService == 1 ? '室内维保' : '通用'
          }}
        </template>
      </el-table-column> -->
      <!-- <el-table-column prop="assess" label="评价信息" show-overflow-tooltip></el-table-column>
      <el-table-column prop="level" label="评分"></el-table-column> -->
      <el-table-column prop="manager" label="审核人员"></el-table-column>
      <!-- <el-table-column prop="appointmentEndTime" label="预约结束" width="150">
          <template slot-scope="{row}"
              v-if="row.appointmentTime">{{Date.formatTime(row.appointmentEndTime)}}</template>
      </el-table-column> -->
      <el-table-column prop="gmtCreate" label="创建时间" width="150">
        <template slot-scope="{row}">{{ Date.formatTime(row.gmtCreate) }}</template>
      </el-table-column>
      <el-table-column label="操作" fixed="right" width="120">
        <template slot-scope="{row}">
          <el-dropdown>
            <el-button type="primary">
              更 多<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item v-if="row.status==1&&row.closeStale!=1" @click.native="sendOrders(row)">派单</el-dropdown-item>
              <!--  -->
              <el-dropdown-item @click.native="getclosedate(row)" v-if="row.closeStale!=1&&row.status==6">关单</el-dropdown-item>
              <el-dropdown-item v-if="row.status==4" @click.native="getupdatedata(row,1)">审核通过</el-dropdown-item>
              <el-dropdown-item v-if="row.status==4" @click.native="getupdatedata(row,0)">审核不通过</el-dropdown-item>
              <el-dropdown-item v-if="row.closeStale==0&&row.status==10" @click.native="getcheckdate(row,1)">关单通过</el-dropdown-item>
              <el-dropdown-item v-if="row.closeStale==0&&row.status==10" @click.native="getcheckdate(row,0)">关单不通过</el-dropdown-item>
              <el-dropdown-item v-if="row.status==2" @click.native="getJiedanPmRepairc(row)">后台接单</el-dropdown-item>
              <el-dropdown-item v-if="row.status==3||row.status==5" @click.native="getOrvuedata(row.id)">确认完成</el-dropdown-item>
              <el-dropdown-item @click.native="getgetRepairComment(row.id)">详情</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <!-- <pay-operate :id="row.id" :xq-id="row.xqId" prefix="BXBY" :reminder="row.payStatus === 0"
            :on_line_refund="havePaid(row) && row.receiptMethod === 'ONLINE'"
            :off_line_refund="havePaid(row) && row.refundStatus !== 'SUCCESS'" :receipt="havePaid(row)"
            :invoice="havePaid(row) && row.refundStatus !== 'SUCCESS'" :charge-off="havePaid(row) && !row.verifyStatus"
            :refresh="getlist">
            <template v-if="$root.btnControl.find(item=>item=='repair_dispatch')">
              <el-dropdown-item :command="() => sendOrders(row)" v-if="row.status==1&&row.closeStale!=1">派单
              </el-dropdown-item>
            </template>
            <template v-if="$root.btnControl.find(item=>item=='repair_close')">
              <el-dropdown-item :command="() => getclosedate(row)" v-if="row.closeStale!=1&&row.status!=10">关单
              </el-dropdown-item>
            </template>
            <template v-if="$root.btnControl.find(item=>item=='repair_check')">
              <el-dropdown-item :command="() => getupdatedata(row,1)" v-if="row.status==4">审核通过
              </el-dropdown-item>
            </template>
            <template v-if="$root.btnControl.find(item=>item=='repair_check')">
              <el-dropdown-item :command="() => getupdatedata(row,0)" v-if="row.status==4">审核不通过
              </el-dropdown-item>
            </template>
           <template v-if="$root.btnControl.find(item=>item=='repair_return')">
              <el-dropdown-item :command="() => returnVisit(row)"
                                v-if="row.status==6">回访
              </el-dropdown-item>
            </template> 
            <template v-if="$root.btnControl.find(item=>item=='repair_close_check')">
              <el-dropdown-item :command="() => getcheckdate(row,1)" v-if="row.closeStale==0&&row.status==10">关单通过
              </el-dropdown-item>
            </template>
            <template v-if="$root.btnControl.find(item=>item=='repair_close_check')">
              <el-dropdown-item :command="() => getcheckdate(row,0)" v-if="row.closeStale==0&&row.status==10">关单不通过
              </el-dropdown-item>
            </template>
            <template v-if="$root.btnControl.find(item=>item=='repair_order')">
              <el-dropdown-item :command="() => getJiedanPmRepairc(row)" v-if="row.status==2">后台接单
              </el-dropdown-item>
            </template>
            <template v-if="$root.btnControl.find(item=>item=='repair_confirm')">
              <el-dropdown-item :command="() => getOrvuedata(row.id)" v-if="row.status==3||row.status==5">确认完成
              </el-dropdown-item>
            </template>
            <template v-if="$root.btnControl.find(item=>item=='view')">
              <el-dropdown-item :command="() => gethetong(row)" v-if="row.status==3||row.status==5">生成合同
              </el-dropdown-item>
            </template>
            <template v-if="$root.btnControl.find(item=>item=='view')">
              <el-dropdown-item :command="() => getgetRepairComment(row.id)">详情</el-dropdown-item>
            </template>
          </pay-operate> -->
        </template>
      </el-table-column>
    </el-table>
    <paging @changePage="handleCurrentPage" :get-total="total" :page.sync="formSearch.current" />

    <!-- 添加 -->
    <el-dialog title="派 单" :visible.sync="addDialog" :close-on-click-modal="false">
       <propertyMaintenance @pushSelect="pushSelectsingle" :typeId="typeId"
                           :xq-id="rowxqId">
      </propertyMaintenance>
      <!--<sendorderssite @pushSelect="pushSelectplural" :rowxqId="rowxqId" v-if="typenum==2 || typenum==3 ">
      </sendorderssite> -->

      <div slot="footer" class="dialog-footer">
        <el-button size="medium " @click="addDialog = false">取 消</el-button>
        <el-button size="medium " @click="addList">派 单</el-button>
      </div>
    </el-dialog>
    <!-- 添加报修单 -->
    <el-dialog title="添加维保单" :visible.sync="showAddBall">
      <div class="cont_box_right">
        <el-form label-position="right" :rules="rules" label-width="90px" :model="ballData" ref="addBall">
          <el-form-item label="选择项目" size="small" prop="projectId">
            <el-select v-model="ballData.projectId" placeholder="请选择项目" @change="xqIdChange">
              <el-option v-for="(item,index) in xqTree" :label="item.name" :value="item.id" :key="index">
              </el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="服务类型" size="small" prop="typeService">
            <el-select v-model="ballData.typeService" placeholder="请选择服务类型" @change="getpmtypePropertyType">
              <el-option label="公区维保" :value="0"></el-option>
              <el-option label="室内报修" :value="1"></el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item label="手机号码" size="small" :prop="ballData.typeService?'phone':''">
            <el-input v-model="ballData.phone" placeholder="请填写已注册的手机号" @blur="getHouseList"></el-input>
          </el-form-item>
          <el-form-item label="维保描述" size="small" prop="desc">
            <el-input v-model="ballData.desc"></el-input>
          </el-form-item>
          <el-form-item v-if="ballData.typeService" label="保修地址" size="small">
            <el-select v-model="house" value-key="id" @change="changeHouse">
              <el-option v-for="item in houseList" :value="item" :key="item.id"
                :label="`${item.sectionName}-${item.name}`" />
            </el-select>
          </el-form-item>
          <el-form-item v-else label="保修地址" size="small">
            <el-input clearable size="small" v-model="ballData.addressWarranty" />
          </el-form-item>
          <!-- <el-form-item label="维保类型" size="small" prop="typeId">
            <el-select v-model="ballData.typeId" placeholder="请选择维保类型">
              <el-option v-for="(item,index) in pmtypePro" :key="index" :label="item.name"
                         :value="item.id"/>
            </el-select>
          </el-form-item> -->
          <!-- <el-form-item label="预约时间" size="small" v-if="ballData.typeService==1">
            <el-date-picker v-model="ballData.appointmentTime" type="datetime" value-format="timestamp"
                            placeholder="预约时间"></el-date-picker>
          </el-form-item> -->

          <el-form-item label="图片" size="small" prop="picture">
            <el-upload ref="Updata" :action="uploadToRealPath" list-type="picture-card" :headers="headers"
              :file-list="fileList" :on-success="handleAvatarSuccess" :on-remove="handleRemove">
              <i class="el-icon-plus"></i>
            </el-upload>
            <el-dialog :visible.sync="dialogVisible">
              <img width="100%" :src="dialogImageUrl" alt />
            </el-dialog>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="medium " @click="showAddBall = false">取 消</el-button>
        <el-button size="medium " @click="addBall('addBall')">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 查看多张图片 -->
    <el-dialog title="图片查看" :visible.sync="showimgs">
      <div class="cont_box_right">
        <el-image style="width: 100%;" :src="showImage" fit="cover"></el-image>
      </div>
    </el-dialog>
    <!-- 回访 -->
    <!-- <el-dialog title="回访" :visible.sync="huifangDialog">
      <div class="cont_box_right">
        <el-form label-position="right" :rules="rules" label-width="90px" :model="huifanObj">
          <el-form-item label="回访内容" size="small">
            <el-input v-model="huifanObj.reviewContent"></el-input>
          </el-form-item>
          <el-form-item label="图片" size="small" prop="picture">
            <el-upload ref="Updata" :action="uploadToRealPath" list-type="picture-card" :headers="headers"
                       :file-list="fileList" :on-success="handleAvatarSuccess" :on-remove="handleRemove">
              <i class="el-icon-plus"></i>
            </el-upload>
            <el-dialog :visible.sync="dialogVisible">
              <img width="100%" :src="dialogImageUrl" alt/>
            </el-dialog>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="medium " @click="huifangDialog = false">取 消</el-button>
        <el-button size="medium " @click="getHuifangdate">确 定</el-button>
      </div>
    </el-dialog> -->
    <!-- 填写表单 -->
    <!-- <el-dialog title="填写表单" :visible.sync="pmtypematerialDialog">
      <div class="cont_box_right">
        <el-form label-position="right" :rules="rules" label-width="90px" :model="pmtypematerialInfor">
          <el-form-item label="物料内容" size="small">
            <el-input v-model="pmtypematerialInfor.content"></el-input>
          </el-form-item>
          <el-form-item label="维保情况" size="small">
            <el-input v-model="pmtypematerialInfor.conditionMaintenance"></el-input>
          </el-form-item>
          <el-form-item label="物料" size="small">
            <div v-for="(item,index) in wuliao" :key="index" :v-if="item.isShow">
              <el-input v-model="item.nameMaterial" placeholder="请输入物料名称"></el-input>
              <span style="margin-right:20px;"></span>
              <el-input-number v-model="item.materialNumber" :min="0" label="物料数量"></el-input-number>
            </div>
            <div>
              <el-button size="small" @click="addWuliao">新增</el-button>
              <el-button size="small" type="danger" @click="deleteWuliao(item)">删除</el-button>
            </div>
          </el-form-item>
          <el-form-item label="图片" size="small" prop="picture">
            <el-upload ref="Updata" :action="uploadToRealPath" list-type="picture-card" :headers="headers"
                       :file-list="fileList" :on-success="handleAvatarSuccess" :on-remove="handleRemove">
              <i class="el-icon-plus"></i>
            </el-upload>
            <el-dialog :visible.sync="dialogVisible">
              <img width="100%" :src="dialogImageUrl" alt/>
            </el-dialog>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="medium " @click="pmtypematerialDialog = false">取 消</el-button>
        <el-button size="medium " @click="getpmtypematerial">确 定</el-button>
      </div>
    </el-dialog> -->
    <!-- 详情 -->
    <el-dialog title="查看详情" :visible.sync="detailsDialog">
      <propertyDetial :repairCommentList="repairCommentList" :type="repairComment.type"></propertyDetial>
      <div slot="footer" class="dialog-footer">
        <el-button size="medium" @click="detailsDialog = false">关 闭</el-button>
      </div>
    </el-dialog>


  </section>
</template>

<script>
  import paging from '../paging';
  import propertyMaintenance from './property_wxrenyuan';
  // import sendorderssite from './sendorders_site';
  import QRCode from 'qrcode';

  import propertyDetial from './property_detial';
  import {
    getRepairComment,//详情
    jiedanPmRepairc,//后台接单
    billrepairApp,//添加保修单
    getupdatedata,//审核
    getRepairData,//查询保修列表
    pmtypCheckdate,//审核关单
    closedate,//关单
    pmtypeOrvuedata,//完成
    pmtypeUpdaData,//派单派维修人员
     delRepairData,//删除保修数据
    xqSelectList,//
  } from '../../url/api';
  // import PayOperate from "../payOperate";

  export default {
    data() {
      return {
        typenum: '', //1维修人员 2网点人员 3维修人员和网点人员
        option1: [],
        fileList: [],
        huifanObj: {},
        QueryDetail: '',
        QueryDetail1: '',
        //扫码跳转参数
        checString: '', //sign
        ddhao: '', //订单号
        cost: 0, //金额
        terminalObj: 1,
        commission: 0, //手续费
        allamount: 0, //总金额
        huifangDialog: false,
        showImage: '',
        xqTree: [],
        // getnamr: [],
        isAddorUpdate: 1, //1添加、2修改
        formSearch: {
          current: 1,
          size: 10,
          projectId: ''
        },
        typeId: '',
        TotalAmount: 0,
        paidangid: '',
        formData: [], //数据
        deleBatch: [], //删除数据
        formUpdate: {}, //修改表单
        total: 0, //数据总数
        pages: 0, //页面总数
        showimgs: false,
        addDialog: false,
        updateDialog: false,
        detailsDialog: false,
        dialog: false,
        formPush: {},
        uploadToRealPath: '/api/v1.0/file/upload/file',
        dataTree: [],
        defaultProps: {
          //树状图key定义
          children: 'data',
          label: 'name',
        },
        url: '',
        bills: [], //获取订单
        //清分参数
        qingfen: {
          agent: 0,
          houseId: this.$route.query.houseId,
          orderId: '',
          payType: '',
          psw: '123456',
          type: 1,
        },
        defaultProps2: {
          children: 'children',
          label: 'name',
          value: 'id',
          expandTrigger: 'hover',
          checkStrictly: true,
        },
        pselectwx: [],
        pselectwd: [],
        headers: {
          Authorization: sessionStorage.getItem('Authorization'),
          token: sessionStorage.getItem('token'),
        },
        rules: {
          name: [{ required: true, message: '该项不能为空' }],
          desc: [{ required: true, message: '该项不能为空' }],
          phone: [{ required: true, message: '该项不能为空' }],
          projectId: [
            {
              required: true,
              message: '该项不能为空',
              trigger: 'blur',
            },
          ],
          typeService: [
            {
              required: true,
              message: '该项不能为空',
              trigger: 'blur',
            },
          ],
        },
        dialogVisible: false,
        dialogImageUrl: '',
        house: {
          id: null,
          name: ''
        },
        ballData: {
          typeId: null,
          typeService: 0,
          houseId: null,
          addressWarranty: '',
        },
        houseList: [],
        propertyType: [], //事务类型
        showAddBall: false,
        pmtypematerialDialog: false,
        pmtypematerialInfor: {}, //tinajiawuye
        wuliao: [
          {
            materialNumber: '',
            nameMaterial: '',
            isShow: true,
          },
        ],
        repairComment: {
          type: 0,
        },
        repairCommentList: {},
        pmtypePro: [], //报修地址报修类型
        rowxqId: '',
      };
    },
    methods: {
      paidan(){
        console.log("点击事件");
        // alert("点击事件")
      },
      sendOrders(row) {
        this.rowxqId = row.projectId;
        this.addDialog = true;
        this.paidangid = row.id;
        this.typeId = row.typeId;
      },
      havePaid(row) {
        return row.payStatus === 1;
      },
      changeHouse(house) {
        if (house) {
          this.ballData.houseId = house.id;
          this.ballData.addressWarranty = `${house.sectionName}-${house.name}`;
        }
      },
      delData() {
        const ids = this.$refs.table.selection.map(item => item.id);
        if (ids.length < 1) {
          return this.$message.warning('请勾选要删除的数据')
        }
        delRepairData(ids).then(({ data }) => {
          if (data.ok) {
            this.$message.success('删除成功')
          } else {
            this.$message.error('删除失败')
          }
        }).finally(() => this.getlist())
      },
      getHouseList() {

      },
      xqIdChange() {
        this.getHouseList()
        // this.getpmtypePropertyType();
      },
      addWuliao() {
        let obj = {
          materialNumber: '',
          nameMaterial: '',
          isShow: true,
        };
        this.wuliao.push(obj);
      },
      deleteWuliao(item) {
        item.isShow = false;
      },

      erweimatiaozhuan() {
        // 　　　this.QueryDetail="操作失败";
        var canvas = document.getElementById('canvas');
        this.QueryDetail =
          'https://www.ubicell.cn/qchpay?checkString=' +
          this.checString +
          '&orderId=' +
          this.ddhao +
          '&cost=' +
          this.cost +
          '&terminalObj=' +
          this.terminalObj;
        console.log(this.QueryDetail);
        console.log('this.commission', this.commission);
        QRCode.toCanvas(canvas, this.QueryDetail, function (error) {
          if (error) console.error(error);
          console.log('success!');
        });
        this.codeShow = true;
      },
      // 切换微信扫码和支付宝扫码
      gettype() {
        console.log(this.qingfen.type);
        if (this.qingfen.type == 1) {
          this.QueryDetail = this.QueryDetail1;
        } else {
          this.qingfen.type = 1;
          alert('暂不支持支付宝支付！');
        }
      },
      handleSelectionChange(val, self) {
        //console.log(val);
        let m = 0;
        val.forEach((item) => {
          m += +item.amount;
        });
        console.log(val);
        this.TotalAmount = m.toFixed(2);
        this.deleBatch = val;
      },

      gethetong(row) {
        //维保合同
        console.log(row);
        this.$router.push({
          query: {
            row: row,
            repairId: row.id,
            desc: row.desc,
          },
          path: '/baoxiuhetong',
        });
      },
      closeCode() {
        this.codeShow = false;
        this.deleBatch = [];
        this.getlist();
        //this.getInit();
      },
      getgetRepairComment(id) {
        //详情和工单轨迹

        this.repairComment.id = id;
        let params = this.repairComment;
        getRepairComment(params).then((res) => {
          console.log(res);
          if (res.data.ok) {
            this.repairCommentList = res.data.data;
            this.detailsDialog = true;
          }
        });
      },
      goProperty_type() {
        //报修类型配置
        this.$router.push({
          path: '/property_maintenance_repair',
          query: {
            type: 0,
          },
        });
      },

      addBall() {
        this.$refs.addBall.validate().then(() => {
          //添加报修单
          let params = this.ballData;
          console.log(params,"添加参数！");
          billrepairApp(params).then((res) => {
            console.log('hello', res);
            if (res.data.ok) {
              this.$message('添加成功');
              this.getlist();
            } else {
              this.$message(res.data.message);
            }
          });
          this.showAddBall = false;
        })
      },
      getJiedanPmRepairc(row, status) {
        //后台接单
        let params = {
          id: row.id,
          type: 0,
        };
        jiedanPmRepairc(params).then((res) => {
          console.log(res);
          if (res.data.ok) {
            this.getlist();
            this.$message('接单成功');
          } else {
            this.$message('接单失败');
          }
        });
      },
      getcheckdate(row, status) {
        //审核关单
        let params = {
          id: row.id,
          status: status,
          type: 0,
        };
        pmtypCheckdate(params).then((res) => {
          console.log(res);
          if (res.data.ok) {
            this.getlist();
            this.$message('审核成功');
          } else {
            this.$message('审核失败');
          }
        });
      },
      getclosedate(row) {
        //报修关单
        let params = {
          ids: [row.id],
          type: 0,
        };
        this.$confirm('确定要关单吗？')
          .then((_) => {
            closedate(params).then((res) => {
              console.log(res);
              if (res.data.ok) {
                this.getlist();
                this.$message('关单成功');
              } else {
                this.$message('关单失败');
              }
            });
          })
          .catch((_) => {
          });
      },
      // pushSelect(val){//选中派单人员
      //   console.log("",val)
      //   this.pselect = val
      // },
      pushSelectsingle(listwx) {
        //派单人唯一
        console.log('维修人pushSelect：', listwx);

        this.pselectwx = [];
        listwx.forEach((val) => {
          this.pselectwx.push(val.id);
        });
        console.log(this.pselectwx);
      },
      pushSelectplural(listwd) {
        //派单网点不唯一(最大10)
        console.log('网点pushSelect：', listwd);
        this.pselectwd = listwd;
      },
      getlist() {
        getRepairData(this.formSearch).then((res) => {
          console.log(res);
          if (res.data.ok) {
            this.formData = res.data.data.records.filter((item) => {
              if (item.picture) {
                item.picture = item.picture
                  .split('_')
                  .filter((ii) => {
                    if (ii) {
                      return ii;
                    }
                  });
              }

              return item;
            });
            this.total = res.data.data.total*1;
          } else {
            this.$message(res.data.message);
          }
        });
      },
      getupdatedata(row, status) {
        //审核确认完成
        let params = {
          id: row.id,
          status: status,
          type: 0,
        };
        getupdatedata(params).then((res) => {
          console.log(res);
          if (res.data.ok) {
            this.$message('更改成功');
            this.getlist();
          }
        });
      },
      getOrvuedata(id) {
        //确认完成
        let params = {
          id: id,
          type: 0, //type0:保修保养1:投诉建议2事务申请
        };
        this.$confirm('确认更改为完成状态吗？')
          .then((_) => {
            pmtypeOrvuedata(params).then((res) => {
              console.log(res);
              if (res.data.ok) {
                this.$message('更改成功');
                this.getlist();
              }
            });
          })
          .catch((_) => {
          });
      },
      getInit() {
        
        xqSelectList({}).then((res) => {
          //项目选择列表
          console.log(res);
          if (res.data.ok) {
            this.xqTree = res.data.data;
            this.ballData.projectId = res.data.data[0].id;
            this.formSearch.projectId = this.xqTree[0].id
            this.getlist();
            // this.getpmtypePropertyType();

          }
        });

      },
      handleChange(value) {
        if (value.length != 0) {
          console.log(value);
          this.formSearch.orgId =
            this.$refs.cascader.getCheckedNodes()[0].data.id;
        } else {
          this.formSearch.orgId = '';
        }
      },
      handleChange1(value) {
        if (value.length != 0) {
          console.log(value);
          this.formPush.orgId =
            this.$refs.cascader.getCheckedNodes()[0].data.id;
        } else {
          this.formPush.orgId = '';
        }
      },
      addList() {
        //添加树状图node节点
        //console.log("你好：",this.pselect.length);

          let params = {
            id: this.paidangid,
            wxId: this.pselectwx,
            type: 0, // 0:保修保养
          };
          // if(this.pselectwd.length>0){
          //   params.wdId=this.pselectwd
          // }
          console.log('改变后', params);
          this.addDialog = false;
          pmtypeUpdaData(params).then((res) => {
            console.log(res);
            if (res.data.ok) {
              this.getlist();
              this.$message({
                message: '派单成功',
                type: 'success',
              });
            } else {
              this.$message('派单失败:' + res.data.msg);
            }
            this.pselectwx = [];
            this.pselectwd = [];
          });
        

        // this.addDialog = false
      },

      handleAvatarSuccess(res, file, fileList) {
        this.ballData.picture = '';
        this.huifanObj.reviewImg = '';
        this.pmtypematerialInfor.picture = '';
        console.log(res, file, fileList);
        fileList.forEach((item) => {
          this.ballData.picture =
            item.response.data[0] + '_' + this.ballData.picture;
          this.huifanObj.reviewImg =
            item.response.data[0] + '_' + this.huifanObj.reviewImg;
          this.pmtypematerialInfor.picture =
            item.response.data[0] +
            '_' +
            this.pmtypematerialInfor.picture;
        });
      },
      handleRemove(file, fileList) {
        console.log(file, fileList);
        this.ballData.picture = '';
        this.pmtypematerialInfor.picture = '';
        this.huifanObj.reviewImg = '';
        this.fileList = fileList;
        fileList.forEach((item) => {
          this.ballData.picture =
            item.response.data[0] + '_' + this.ballData.picture;
          this.huifanObj.reviewImg =
            item.response.data[0] + '_' + this.huifanObj.reviewImg;
          this.pmtypematerialInfor.picture =
            item.response.data[0] +
            '_' +
            this.pmtypematerialInfor.picture;
        });
      },
      handleSelectionChange(val, self) {
        //多选
        this.deleBatch = val;
        console.log(this.deleBatch);
      },
      handleCurrentPage(val) {
        //页码改变
        this.formSearch.current = val;
        this.getlist();
      },
      checkImg(item) {
        //点击查看多张图片
        this.showImage = item;
        this.showimgs = true;
      },
    },
    mounted() {
      this.getInit();
    },
    components: {
      // PayOperate,
      paging,
      propertyDetial,
      propertyMaintenance,
      // sendorderssite,
    },
  };
</script>

<style scoped lang="scss">
  .export_template .operateBtn {
    position: absolute;
    right: 20px;
    top: 10px;
  }

  .form_inline {
    margin-left: 10px;
  }

  .btn {
    margin: 0 0 20px 10px;
    position: relative;

    .posRight {
      // position: absolute;
      // right: 20px;
      float: right;
      margin-right: 40px;
    }

    .posRight::after {
      display: block;
      content: '';
      clear: both;
    }
  }

  .canvasDiv {
    margin-top: 200px;
    position: relative;
    height: 228px;
    margin-bottom: 20px;
  }

  .canvasDiv canvas {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  #query {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
  }

  .showpayway {
    margin: 0 auto;
    text-align: center;
    width: 280px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    margin-bottom: 20px;
  }

  .showpayway span {
    display: flex;
    align-items: center;
  }

  .butdiv {
    display: flex;
    align-items: center;
    justify-items: center;
  }

  .butdiv button {
    margin: 0 auto;
  }

  .add_form_inline /deep/ .el-input__inner {
    max-width: 150px;
  }
</style>